const fs = require('fs')

/**
 * 从文件流中读取数据
 */
const frs = fs.createReadStream('./pan/pan.txt')

let count = 0
let data = ''
frs.on('data', (chunk) => {
  console.log('###### data ######')
  count += 1
  data += chunk
  console.log(`第${count}次接收到：${chunk}`)
})

frs.on('end', () => {
  console.log('###### end ######')
  console.log(count)
  // console.log(data)
})

frs.on('error', (error) => {
  console.log('###### error ######')
  console.log(error)
})